import React from 'react'
import { Breadcrumb } from 'antd';
import 'antd/dist/antd.css';
import '../../config';
import './switchCity.css'

import cartMehtod from '../../publicMethod.js'
class SwitchCity extends React.Component{
    constructor(props) {
        super(props);
        this.state = {

        }
    }
    city(e) {
		cartMehtod.city=e.target.innerText;
        // console.log(e.target.innerText);
        this.props.history.push('/home');
	}
    render() {
        return (
            <div className="bgSwitchCity">
                <div>
                    <Breadcrumb className="mianbaoxie">
                        您当前的位置：
                        <Breadcrumb.Item>{cartMehtod.city}</Breadcrumb.Item>
                        <Breadcrumb.Item>
                            <a href="###">切换城市</a>
                        </Breadcrumb.Item>
                    </Breadcrumb>
                </div>
                <div className="switchCities">
                    <div className="hotcity">
                        <div><p>当前城市：<span>{cartMehtod.city}</span></p></div>
                        <div><p>热门城市：<span onClick={this.city.bind(this)}>北京</span><span onClick={this.city.bind(this)}>上海</span><span onClick={this.city.bind(this)}>天津</span><span onClick={this.city.bind(this)}>深圳</span></p></div>
                        <div><p>最近访问：<span onClick={this.city.bind(this)}>北京</span><span onClick={this.city.bind(this)}>深圳</span></p></div>
                    </div>
                        
                    <ul className="adr">{global.constants.cities.map((item, i) => {
                        return (
                            <li key={i}>
                                <div className="serial"><span>{item.serial}</span></div>
                                <div className="addre"><span>
                                {
                                    item.city.map((t,ii) => {
                                        return (
                                            <span className="aba" target='_self' key={ii} onClick={this.city.bind(this)}>{t}</span>
                                        )
                                    })
                                }
                                </span></div>
                            </li>)
                        })
                    }</ul>
                </div>
            </div>
        );
    }
}
export default SwitchCity;